package edu.whut.mall.portal.mapper;

import edu.whut.mall.model.GroupBuyOrder;
import edu.whut.mall.model.GroupBuyRecord;
import edu.whut.mall.model.PayInfo;
import edu.whut.mall.portal.vo.GroupBuyOrderVo;
import edu.whut.mall.portal.vo.GroupBuyRecordDetailVo;
import edu.whut.mall.portal.vo.GroupBuyRecordVo;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * @program: d9lab-mall
 * @description: 自定义团购订单Mapper
 * @author: Wayne
 * @create: 2020-05-24 16:06
 **/
public interface GroupBuyOrderCustomMapper {
    /**
     * 根据订单号获取订单
     * @param orderNo
     * @return
     */
    GroupBuyOrder queryGroupBuyOrderByOrderNo(String orderNo);

    /**
     * 根据订单号更新状态
     * 支付状态、更新时间、支付时间
     * @param record
     * @return
     */
    Integer updateGroupBuyOrderByOrderNo(GroupBuyOrder record);

    /**
     * 根据recordId来获取订单详情
     * @param recordId
     * @return
     */
    GroupBuyRecordDetailVo getGroupBuyRecordDetailVoByRecordId(Long recordId);

    /**
     * 获取团购超时的订单
     * @return
     */
    List<GroupBuyRecord> getExpireGroupBuyOrders();

    /**
     * 获取用户参与的团购记录
     * @param userId
     * @param status
     * @return
     */
    List<GroupBuyRecordVo> getGroupBuyRecordVosByUserIdAndRecordStatusAndUserType(@Param("userId")Long userId, @Param("status")Integer status, @Param("userType")Integer userType);

    /**
     * 根据规则和状态获取团购记录
     * @param ruleId
     * @param status
     * @return
     */
    List<GroupBuyRecordVo> getGroupBuyRecordVosByRuleIdAndStatus(@Param("ruleId")Long ruleId, @Param("status")Integer status);

    /**
     * 根据recordId和userId获取订单详情
     * @param recordId
     * @param userId
     * @return
     */
    GroupBuyOrderVo getGroupBuyOrderVoByRecordIdAndUserId(@Param("recordId")Long recordId, @Param("userId")Long userId);

    /**
     * 查看是否已经加入了此次团购
     * @param recordId
     * @param userId
     * @return
     */
    int checkIfJoinedGroupBuyRecord(@Param("recordId")Long recordId, @Param("userId")Long userId);

    /**
     * 根据订单更新支付信息状态
     * @param payInfo
     * @return
     */
    Integer updatePayInfoStatusByOrderNo(PayInfo payInfo);

    /**
     * 根据订单状态来获取订单
     * @param userId
     * @param orderStatus
     * @return
     */
    List<GroupBuyOrderVo> getGroupBuyOrderVoByOrderStatus(@Param("userId")Long userId, @Param("orderStatus")Integer orderStatus);

    /**
     * 根据订单号获得订单详情
     * @param orderNo 订单号
     * @return
     */
    GroupBuyOrderVo getGroupBuyOrderVoByOrderNo(String orderNo);

    /**
     * 确认收货
     * @param orderNo
     * @return
     */
    Integer confirmReceipt(@Param("orderNo") String orderNo);

    /**
     * 删除订单
     * @param orderNo
     * @return
     */
    Integer deleteOrder(@Param("orderNo") String orderNo);

}
